#include<iostream>
#include<string.h>
#include<memory.h>
using namespace std;

void 
rmDumplicate0(char* str)
{
	if(str==NULL)  return ;
	int len=strlen(str);
	if(len<2)  return ;
	int i,j;
	int tail=1;
	for(i=1;i<len;i++)
	{
		for(j=0;j<tail;j++)
		{
			if(str[j]==str[i])  break;
		}
		if(j==tail)  
		{
			str[tail]=str[i];
			tail++;
		}	
	}
	str[tail]='\0';
}

void 
rmDumplicate1(char* str)
{
	if(str==NULL)  return ;
	int len=strlen(str);
	if(len<2) return ;
	for(int i=0;i<len-1;i++)
	{
		for(int j=i+1;j<len;j++)
		{
			if(str[i]==str[j])  
			{
				str[j]=' ';
			}
		}
	}
}

void rmDumplicate2(char* str)
{
	if(str==NULL) return ;
	int len=strlen(str);
	if(len<2)  return ;
	bool hit[256];
	memset(hit,0,sizeof(hit));
	hit[str[0]]=true;
	int tail=1;
	for(int i=1;i<len;i++)
	{
		if(hit[str[i]]==false)
		{
			str[tail++]=str[i];		
			hit[str[i]]=true;
		}
	}
	str[tail]='\0';
}

void 
rmDumplicate3(char* str)
{
	if(str==NULL)  return ;
	int len=strlen(str);
	if(len<2) return ;
	int checker=0,tail=0;
	for(int i=0;i<len;i++)
	{
		int val=(int)(str[i]-'a');
		if( ( checker & (1<<val) ) == 0 )
		{
			str[tail++]=str[i];
			checker |= (1<<val);
		}
	}
	str[tail]='\0';
}

int main()
{
	char s1[][10]={"abcde","abcde","abcde","abcde"};
	char s2[][10]={"aaabbb","aaabbb","aaabbb","aaabbb"};
	char s3[][10]={"","","",""};
	char s4[][10]={"abababa","abababa","abababa","abababa"};
	char s5[][10]={"aaaa","aaaa","aaaa","aaaa"};
	cout<<"Case 1:"<<endl;
	rmDumplicate0(s1[0]);
	cout<<s1[0]<<endl;
	rmDumplicate1(s1[1]);
	cout<<s1[1]<<endl;
	rmDumplicate2(s1[2]);
	cout<<s1[2]<<endl;
	rmDumplicate3(s1[3]);
	cout<<s1[3]<<endl;
	
	cout<<"Case 2:"<<endl;
	rmDumplicate0(s2[0]);
	cout<<s2[0]<<endl;
	rmDumplicate1(s2[1]);
	cout<<s2[1]<<endl;
	rmDumplicate2(s2[2]);
	cout<<s2[2]<<endl;
	rmDumplicate3(s2[3]);
	cout<<s2[3]<<endl;

	cout<<"Case 3 :"<<endl;
	rmDumplicate0(s3[0]);
	cout<<s3[0]<<endl;
	rmDumplicate1(s3[1]);
	cout<<s3[1]<<endl;
	rmDumplicate2(s3[2]);
	cout<<s3[2]<<endl;
	rmDumplicate3(s3[3]);
	cout<<s3[3]<<endl;

	cout<<"Case 4 :"<<endl;
	rmDumplicate0(s4[0]);
	cout<<s4[0]<<endl;
	rmDumplicate1(s4[1]);
	cout<<s4[1]<<endl;
	rmDumplicate2(s4[2]);
	cout<<s4[2]<<endl;
	rmDumplicate3(s4[3]);
	cout<<s4[3]<<endl;

	cout<<"Case 5 :"<<endl;
	rmDumplicate0(s5[0]);
	cout<<s5[0]<<endl;
	rmDumplicate1(s5[1]);
	cout<<s5[1]<<endl;
	rmDumplicate2(s5[2]);
	cout<<s5[2]<<endl;
	rmDumplicate3(s5[3]);
	cout<<s5[3]<<endl;

	return 0;
}



